module utils.perfcount;

import std.stdio;

version(Windows) {
    import std.c.windows.windows;

    private double mPerfToMus;

    public void initPerf() {
        long freq;
        QueryPerformanceFrequency(&freq);
        mPerfToMus = (cast(double)1000*1000)/freq;
    }

    public long queryPerfMicros() {
        long t;
        QueryPerformanceCounter(&t);
        return cast(long)(t*mPerfToMus);
    }
}

version(linux) {
    import std.c.time;

    public void initPerf() {
        //
    }

    public long queryPerfMicros() {
        clock_t t = clock();
        return t*(1000*1000/CLOCKS_PER_SEC);
    }
}
